
import api from '../../api/index'
import { userInfoStore } from '../../store/userInfo'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userLevel: 0,
    banners: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({ userLevel: userInfoStore.userInfo.level })
    var self = this;
    api.getbanner({ pageNo: 11 }).then(res => {
      self.setData({
        banners: res.result
      })
    })


  },

  godetail:function(e) {
    let url = 'https://www.daikin1995.com/upload/decorate/decorate_' + e.currentTarget.dataset.index + '.png';
    let title = e.currentTarget.dataset.title;
    wx.navigateTo({
      url: '../imagePage/index?title=' + title + '&url=' + url
    })
  },

  gonext: function (e) {
    let index = e.currentTarget.dataset.index;
    let url = 'https://mp.weixin.qq.com/s/M_ao282649UxYPOjigN-hQ';
    if (index == 2) url = 'https://mp.weixin.qq.com/s/mNBuGWBqpiMqjG3qEBEAXw'
    wx.navigateTo({
      url: '../webView/index?url=' + encodeURIComponent(url),
    })
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let giftBag = this.selectComponent("#giftbag");
    getApp().displayGiftBag(giftBag);
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    getApp().share();
  }
})